/*************************************************************************
	> File Name: hzoj_375.cpp
	> Author: zhangxu 
	> Mail: walrus1983@126.com
	> Created Time: 一  9/ 2 16:21:38 2024
 ************************************************************************/

#include<iostream>
#include <ostream>
#include <vector>
#include <algorithm>
using namespace std;

class Student {
public:
	int num;
	int x1, x2, x3;
	Student(int num, int x1, int x2, int x3) :num(num), x1(x1), x2(x2), x3(x3) {}

};

bool cmp(const Student &i, const Student &g) {
	if((i.x1 + i.x2 + i.x3) == (g.x1 + g.x2 + g.x3)) {
			if(i.x1 == g.x1) return i.num < g.num;
			else return i.x1 > g.x1;
		}
	else return (i.x1 + i.x2 + i.x3) > (g.x1 + g.x2 + g.x3);


}
ostream &operator<<(ostream& out, const Student& obj) {
	out << "No " << obj.num << ": " << obj.x1 << ", " << obj.x2 << ", " << obj.x3 << endl;
	return out;
}
int main() {
	int n;
	cin >> n;
	vector<Student> arr;
	for(int i = 0, a, b, c; i < n; i++) {
		cin >> a >> b >> c;
		Student temp(i + 1, a, b, c);
		arr.push_back(temp);
	}
	sort(arr.begin(), arr.end(), cmp);
	for(int i = 0; i < 5; i++) {
		cout << arr[i].num << " " << arr[i].x1 + arr[i].x2 + arr[i].x3 << endl;
	}
	return 0;
}